package com.wekatest;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

/*import weka.classifiers.Classifier;
import weka.classifiers.bayes.NaiveBayes;
import weka.core.*;*/

public class WekaTestInstance
{
    /*Instances m_Data = null;
    Classifier m_Classifier = null;
    public WekaTestInstance() throws FileNotFoundException, Exception
    {
        m_Classifier = (NaiveBayes)SerializationHelper.read(new FileInputStream("model/bayes.model"));

        String nameOfDataset = "messDataset";
        FastVector attributes = new FastVector();
        attributes.addElement(new Attribute("aa"));
        attributes.addElement(new Attribute("bb"));

        FastVector fvNominalVal = new FastVector(3);
        fvNominalVal.addElement("blue");
        fvNominalVal.addElement("gray");
        fvNominalVal.addElement("black");
        attributes.addElement(new Attribute("Nominal", fvNominalVal));

        FastVector classValues = new FastVector(2);
        classValues.addElement("pos");
        classValues.addElement("neg");
        attributes.addElement(new Attribute("Class", classValues));
        m_Data = new Instances(nameOfDataset, attributes, 10);
        m_Data.setClassIndex(m_Data.numAttributes()-1);
    }
    public void classifyMessage(double aa,double bb,String nominal) throws Exception
    {
        Instances testset = m_Data.stringFreeStructure();
        Instance instance = makeInstance(aa,bb,nominal,testset);
        System.out.println(m_Data.numAttributes());
        System.out.println(instance);
        double predicted = m_Classifier.classifyInstance(instance);
        System.out.println("predicted:"+predicted);
        System.out.println("Message classified as : " +
                m_Data.classAttribute().value((int)predicted));
    }
    private Instance makeInstance(double aa,double bb,String nominal,Instances data)
    {
        Instance instance = new DenseInstance(4);
        instance.setDataset(data);
        Attribute aaAtt = data.attribute("aa");
        Attribute bbAtt = data.attribute("bb");
        Attribute nominalAtt = data.attribute("Nominal");

        instance.setValue(aaAtt, aa);
        instance.setValue(bbAtt, bb);
        instance.setValue(nominalAtt, nominal);

//		instance.setValue((Attribute)instance.attribute(0), aa);
//		instance.setValue((Attribute)instance.attribute(1), bb);
//		instance.setValue((Attribute)instance.attribute(2),nominal);
        return instance;
    }
    public static void main(String[] args) throws Exception
    {
        WekaTestInstance wTestInstance = new WekaTestInstance();
        wTestInstance.classifyMessage(5.6,9.9,"gray");
    }*/

}
